package com.kqb.sgai.config;

import com.kqb.sgai.advisor.MyLoggerAdvisor;
import com.kqb.sgai.chatmemory.MongodbChatMemory;
import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.InMemoryChatMemory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 杉果树皮
 */
@Configuration
public class AiConfig {


    @Resource
    private ChatMemory chatMemory;

    @Bean
    public ChatClient dashScopeClient(ChatClient.Builder builder) {
//        InMemoryChatMemory chatMemory = new InMemoryChatMemory();
        return builder

                .defaultAdvisors(new MyLoggerAdvisor())
                .defaultAdvisors(new MessageChatMemoryAdvisor(chatMemory))
                .build();

    }

}
